package jmars.mobile.misc;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class ExtractMCC460Cell {

	private static String out="E:\\BaiduYunDownload\\afterprocess\\MCC460GEO.CSV";
	private static String in="E:\\BaiduYunDownload\\data\\cell_towers.csv";
	public static void main(String[] args) throws IOException{
		String row;
		String[] cols;
		FileWriter resultWriter;
		resultWriter = new FileWriter(out);
		File fin = new File(in);
		FileInputStream fis = new FileInputStream(fin);
		BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
		int headercount=0;
		resultWriter.write("%mcc,mnc,lac,cellId,long,lat,samples,changeable,created,updated,averageSignalStrength\r\n");
		while((row=reader.readLine())!=null){
			if(headercount<=0){
				headercount++;
				continue;
			}
			cols=row.split(",");
			if("460".equals(cols[0])){
				headercount++;
				resultWriter.write(row+"\r\n");
				if(headercount%1000==0)System.out.println(headercount);
			}
		}
		fis.close();
		resultWriter.close();
		System.out.println("finished.");
	}
	

}
